<?php

declare(strict_types=1);

namespace App;

use Hyperf\Contract\ApplicationInterface;
use Hyperf\Server\ServerFactory;
use Psr\Container\ContainerInterface;

class Application implements ApplicationInterface
{
    public function __construct(
        private ContainerInterface $container
    ) {
    }

    public function run(): void
    {
        try {
            $serverFactory = $this->container->get(ServerFactory::class);
            $serverFactory->start();
        } catch (\Throwable $e) {
            echo "Gateway startup error: " . $e->getMessage() . "\n";
            echo "Stack trace: " . $e->getTraceAsString() . "\n";
            throw $e;
        }
    }
}
